/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author Administrator
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        // Tạo Connection
        MySqlConnect connect = new MySqlConnect("localhost", "root", "", "SinhViendb");

        ResultSet result = connect.excuteQuery("Select * From sinhvien");
        System.out.println(CountRow(result));

        result = connect.excuteQuery("Select * From sinhvien Where MaSV=1");
        System.out.println(CountRow(result));
        connect.Close();


    }
    // Đếm số dùng trong Resource
    protected static int CountRow(ResultSet result) throws SQLException{
        int count=0;
        while(result.next()){
            count++;
            //result.getObject("TenHS");
            //result.getObject("TenHS");
        }
        System.out.print("");
        return count;
    }
}
